--kill_probability
-- created by wangy
-- 生命值低于{0}%，{1}%概率被直接击杀

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 攻击时触发
    trigger = function(who, prop, arg)
        local monster = arg
       -- boss无反应
        if OBJECT_TYPE_MONSTER == monster.type and monster:isBoss() then
            return false;
        end

        local maxHp = monster:getMaxHp();
        local hp    = monster:getHp();
        local reta  = math.modf(hp / maxHp * 1000);

        -- 生命%是否低于
        if reta > tonumber(prop[2]) then
            return false;
        end

        local rand = DungeonM.getRandSeed("KILL_PROBA");
        -- 概率没发生
        if rand % 1000 > prop[3] then
            return false;
        end

            return true;
    end,

    record = function(target, prop, path)
        return false;
    end
};
